package com.ruoyi.merchantdata.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum DataStatusEnum {

    /**
     * 待跟进 已跟进 已上门 已签约 进件中 已放款 已收款
     */
    MAKE_SPACE(-4, "空号"),
    TROUBLE_APPLY(-3, "捣乱申请"),
    OTHER_APPLY(-2, "异地申请"),
    CANNOT_ENOUGH(-1, "贷款资质不足"),
    WAIT_FOLLOW(0, "待跟进"),
    HAD_FOLLOW(1, "待签约"),
    COME_SEE(2, "已上门"),
    SIGN_CONTRACT(3, "已签约"),
    TO_BUSINESS(4, "进件中"),
    MAKE_LOAN(5, "已放款"),
    MAKE_COLLECT(6, "已收款"),
    ;

    Integer value;
    String name;

    DataStatusEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(Integer value){
        for (DataStatusEnum item: values()){
            if (ObjectUtil.equal(item.getValue(), value)){
                return item.getName();
            }
        }
        return value+"";
    }

    public static List<Map<String, Object>> getMapList(){

        List<Map<String, Object>> resultList = new ArrayList<>();
        for (DataStatusEnum item: values()){
            Map<String, Object> map = new HashMap<>();
            map.put("name", item.getName());
            map.put("value", item.getValue());
            resultList.add(map);
        }
        return resultList;
    }

}
